package com.android.questions.ui.activity;

import android.text.TextUtils;
import android.view.View;

import androidx.viewbinding.ViewBinding;

import com.android.base.ui.base.VBBaseActivity;
import com.android.base.util.ActivityClickUtil;
import com.android.base.util.ToastUtil;
import com.android.questions.R;
import com.android.questions.databinding.ActivityFeedbackBinding;

/**
 * FileName: FeedBackActivity
 * Author: admin
 * Date: 2021/11/1 18:48
 * Description:
 */
public class FeedBackActivity extends VBBaseActivity implements View.OnClickListener {

    private ActivityFeedbackBinding feedbackBinding;

    @Override
    public ViewBinding getViewBinding() {
        setTitleBackground(BG_BLACK);
        return feedbackBinding = ActivityFeedbackBinding.inflate(getLayoutInflater());
    }

    @Override
    public void initView() {
        super.initView();
        ActivityClickUtil.getInstance().clear();

        feedbackBinding.tvTitle.setText(getString(R.string.text_feedback));
    }

    @Override
    public void initLister() {
        super.initLister();
        feedbackBinding.btnSubmit.setOnClickListener(this);
        feedbackBinding.imgBack.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        if (ActivityClickUtil.getInstance().isFastClick()) {
            //防止用户快速点击
            return;
        }
        if (v.getId() == R.id.imgBack) {
            finish();
        } else if (v.getId() == R.id.btnSubmit) {
            String content = feedbackBinding.edContent.getText().toString().trim();
            String phone = feedbackBinding.edPhone.getText().toString().trim();
            if (TextUtils.isEmpty(content)) {
                ToastUtil.showShortToast(this, "反馈内容不能为空");
                return;
            }
            if (TextUtils.isEmpty(phone)) {
                ToastUtil.showShortToast(this, "联系方式不能为空");
                return;
            }
            ToastUtil.showShortToast(this, "提交成功");
            finish();
        }
    }
}
